local skel = fk.CreateSkill {
  name = "emo__fenjie",
}

Fk:loadTranslationTable{
  ["emo__fenjie"] = "分解",
  [":emo__fenjie"] = "出牌阶段限一次，你可以弃置一张基本牌：若你有“硬币”，视为使用一张不计入次数的【杀】；若没有，摸两张伤害牌。",

  ["#emo__fenjie-prompt1"] = "分解:弃置1张基本牌，视为使用【杀】",
  ["#emo__fenjie-prompt0"] = "分解:弃置1张基本牌，摸2张伤害牌",

  ["$emo__fenjie1"] = "下次也让我好好享受吧",
  ["$emo__fenjie2"] = "看你能坚持到什么时候",
}

skel:addEffect("active", {
  anim_type = "offensive",
  card_num = 1,
  target_num = 0,
  prompt = function (self, player)
    return "#emo__fenjie-prompt".. player:getMark("@@emo__coin")
  end,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeBasic
    and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:throwCard(effect.cards, skel.name, player, player)
    if player.dead then return end
    if player:getMark("@@emo__coin") > 0 then
      room:askToUseVirtualCard(player, {
        name = "slash", skill_name = skel.name, cancelable = false, skip = false, extra_data = {bypass_distances = true, bypass_times = true}
      })
    else
      local cards = table.filter(room.draw_pile, function (id)
        return Fk:getCardById(id).is_damage_card
      end)
      if #cards > 0 then
        room:obtainCard(player, table.random(cards, 2), false, fk.ReasonPrey, player, skel.name)
      end
    end
  end,
})

return skel
